﻿namespace Bowlus.Common
{
    using System.Collections.Generic;
    using System.Net;
    using Common;
    using System.Web.Script.Serialization;
    using System.Linq;

    public class ApplicationHost
    {
        public string Status { get; set; }

        public string InstanceId { get; set; }

        public IPEndPoint DeploymentManagerEndpoint { get; set; }

        public IEnumerable<TenantDeployment> Deployments { get; set; }

        public ApplicationHost() { }

        public ApplicationHost(string jsonString)
        {
            var values = new JavaScriptSerializer().Deserialize<Dictionary<string, string>>(jsonString);
            this.Status = values["Status"];
            this.InstanceId = values["InstanceId"];
        }

        public string Serialize()
        {
            var values = new Dictionary<string, string>()
                {
                    { "Status", this.Status },
                    { "InstanceId", this.InstanceId }
                };

            return new JavaScriptSerializer().Serialize(values);
        }
    }
}
